/*
 * Copyright (c) 2020 - present, Inspur Genersoft Co., Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.inspur.edp.udt.generator.core.rtgenerator.entity;


import com.inspur.edp.caf.generator.BaseGenerator;
import com.inspur.edp.caf.generator.baseInfo.TypeInfo;
import com.inspur.edp.caf.generator.field.FieldGenerator;
import com.inspur.edp.caf.generator.method.ClassMethodGenerator;
import com.inspur.edp.cef.gencommon.MediateType;
import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.EntityDataImplGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.ValueObjectImplGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.field.ResourceInfoFieldGenerator;
import com.inspur.edp.cef.generator.coreGenerator.base.entitygen.method.GetResInfoGenerator;
import com.inspur.edp.cef.spi.entity.info.CefEntityTypeInfo;
import com.inspur.edp.udt.core.Udt.AbstractUdt;
import com.inspur.edp.udt.generator.api.mgrinterface.UdtGetResInfoGenerator;
import com.inspur.edp.udt.generator.api.mgrinterface.UdtResourceInfoFieldGenerator;
import com.inspur.edp.udt.generator.core.rtgenerator.entity.data.UdtDataImplGenerator;
import com.inspur.edp.udt.generator.core.rtgenerator.entity.dtms.UdtCreateAfterCreateDtmAssMethodGenerator;
import com.inspur.edp.udt.generator.core.rtgenerator.entity.dtms.UdtCreateAfterModifyDtmAssMethodGenerator;
import com.inspur.edp.udt.generator.core.rtgenerator.entity.dtms.UdtCreateBeforeSaveDtmAssMethodGenerator;
import com.inspur.edp.udt.generator.core.rtgenerator.entity.method.GetCacheInfoMethodGenerator;
import com.inspur.edp.udt.generator.core.rtgenerator.entity.method.UdtCtorGenerator;
import com.inspur.edp.udt.generator.core.rtgenerator.entity.method.UdtGetCacheInfoFieldGenerator;
import com.inspur.edp.udt.generator.core.rtgenerator.entity.vals.UdtCreateAfterModifyValAssMethodGenerator;
import com.inspur.edp.udt.generator.core.rtgenerator.entity.vals.UdtCreateBeforeSaveValAssMethodGenerator;
import java.util.ArrayList;

public class UdtImplGenerator extends ValueObjectImplGenerator
{
	private UdtEntityGenCtx entityGenCtx;
	public UdtImplGenerator(UdtEntityGenCtx entityGenCtx, String nodeCode)
	{
		super(entityGenCtx, entityGenCtx.getNode());
		this.entityGenCtx = entityGenCtx;
	}

	@Override
	protected Class getParentClass() {
		return AbstractUdt.class;
	}

	@Override
	protected ClassMethodGenerator getDataTypeCacheInfoMethodGenerator() {
		return new GetCacheInfoMethodGenerator();
	}

	@Override
	protected ClassMethodGenerator getCreateAfterCreateDtmAssMethodGenerator()
	{
		return new UdtCreateAfterCreateDtmAssMethodGenerator(getDataTypeImplContext(),entityGenCtx.getNode().getCode());
	}

	@Override
	protected ClassMethodGenerator getCreateAfterModifyDtmAssMethodGenerator()
	{
		return new UdtCreateAfterModifyDtmAssMethodGenerator(getDataTypeImplContext(),entityGenCtx.getNode().getCode());
	}

	@Override
	protected ClassMethodGenerator getCreateAfterModifyValAssMethodGenerator()
	{
		return new UdtCreateAfterModifyValAssMethodGenerator(getDataTypeImplContext(),entityGenCtx.getNode().getCode());
	}

	@Override
	protected ClassMethodGenerator getCreateBeforeSaveDtmAssMethodGenerator()
	{
		return new UdtCreateBeforeSaveDtmAssMethodGenerator(getDataTypeImplContext(),entityGenCtx.getNode().getCode());
	}

	@Override
	protected ClassMethodGenerator getCreateBeforeSaveValAssMethodGenerator()
	{
		return new UdtCreateBeforeSaveValAssMethodGenerator(getDataTypeImplContext(),entityGenCtx.getNode().getCode());
	}

	@Override
	protected EntityDataImplGenerator getDataGenerator(MediateType baseType)
	{
		return new UdtDataImplGenerator(entityGenCtx, entityGenCtx.getNode().getCode(), baseType);
	}

	@Override
	protected void addValueExtendParentInterfaces(ArrayList<TypeInfo> arrayList) {

	}

	@Override
	protected ClassMethodGenerator getConstructorGenerator(String typeName, String dataName)
	{
		return new UdtCtorGenerator(typeName, dataName);
	}

	@Override
	protected FieldGenerator getDataTypeCacheInfoFieldGenerator() {
		return new UdtGetCacheInfoFieldGenerator();
	}

	@Override
	protected void afterGenerate()
	{
		super.afterGenerate();

	}

	@Override
	protected GetResInfoGenerator getResouceInfoMethodGenerator() {
		return new UdtGetResInfoGenerator(resInfoName, dataType.getCode(), ParentContext);
	}

	@Override
	protected ResourceInfoFieldGenerator getResourceInfoFieldGenerator() {
		return new UdtResourceInfoFieldGenerator(resInfoName);
	}

	@Override
	protected ArrayList<BaseGenerator> createClassExtendChildGenrators() {
		ArrayList<BaseGenerator> list = super.createClassExtendChildGenrators();
		if(list==null)
			list=new ArrayList<BaseGenerator>();
//		list.add(new UdtDtmsGenerator(this.getDataTypeImplContext()));
//		list.add(new UdtValidationsGenerator(getDataTypeImplContext()));
		return list;
	}
}
